/**
 * 加密相关工具函数
 */

/**
 * 生成安全的随机字符串
 * @param {number} length - 字符串长度，默认24
 * @returns {string} 随机字符串
 */
export function generateSecureRandomString(length = 24) {
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  const randomValues = new Uint32Array(length);
  window.crypto.getRandomValues(randomValues);
  let result = "";
  randomValues.forEach((value) => {
    result += chars[value % chars.length];
  });
  return result;
}